﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NLBS.Web;

namespace NLBS.Data
{
    public partial class blog_Article
    {
        public static void InsertArticle(blog_Article art)
        {
            art.LogID = Guid.NewGuid();
            art.PostTime = DateTime.Now;
            art.CatID = new Guid("9e7f395a-4da6-4903-b1c9-3948b672ea20");
            art.AuthorID = new Guid("97dacc0f-91a5-47be-990e-8821b8c632c2");
            art.PathID = new Guid("9e7f395a-4da6-4903-b1c9-3948b672ea21");
            art.LogIP = RequestWrapper.IP;
            BlogDataContext database = new BlogDataContext();
            database.blog_Articles.InsertOnSubmit(art);
            database.SubmitChanges();
        }

        public blog_Article Prev
        {
            get
            {
                BlogDataContext database = new BlogDataContext();
                return database.blog_Articles.Where(e => e.PostTime < this.PostTime).OrderByDescending(e => e.PostTime).FirstOrDefault<blog_Article>();
            }
        }
        public blog_Article Next
        {
            get
            {
                BlogDataContext database = new BlogDataContext();
                return database.blog_Articles.Where(e => e.PostTime > this.PostTime).OrderByDescending(e => e.PostTime).FirstOrDefault<blog_Article>();
            }
        }

    }
}
